/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-09 17:29:58
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-09 17:31:12
 * @Description: file content
 */

#include "apue.h"

static void sig_usr(int);

int main(void)
{
    if (signal(SIGUSR1, sig_usr) == SIG_ERR)
    {
        err_sys("can't catch SIGUSR1");
    }

    if (signal(SIGUSR2, sig_usr) == SIG_ERR)
    {
        err_sys("can't catch SIGUSR2");
    }

    for (;;)
    {
        pause();
    }
}

static void sig_usr(int signo)
{
    if (SIGUSR1 == signo)
    {
        printf("received SIGUSR1\n");
    }
    else if (SIGUSR2 == signo)
    {
        printf("received SIGUSR2\n");
    }
    else
    {
        err_dump("received signal %d\n", signo);
    }
}
